<html>
<head><meta charset="utf-8"><title>code coverage · t-compiler/wg-profile-guided-optimization · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/187830-t-compiler/wg-profile-guided-optimization/index.html">t-compiler/wg-profile-guided-optimization</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/187830-t-compiler/wg-profile-guided-optimization/topic/code.20coverage.html">code coverage</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="163630156"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187830-t-compiler/wg-profile-guided-optimization/topic/code%20coverage/near/163630156" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Phil H <a href="https://rust-lang.github.io/zulip_archive/stream/187830-t-compiler/wg-profile-guided-optimization/topic/code.20coverage.html#163630156">(Apr 18 2019 at 07:52)</a>:</h4>
<p>heya, just curious. Is profile guided optimization a prerequisite for instrumenting LLVM to get coverage information for rustc code?</p>



<a name="163630180"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187830-t-compiler/wg-profile-guided-optimization/topic/code%20coverage/near/163630180" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Phil H <a href="https://rust-lang.github.io/zulip_archive/stream/187830-t-compiler/wg-profile-guided-optimization/topic/code.20coverage.html#163630180">(Apr 18 2019 at 07:53)</a>:</h4>
<p>I found <a href="https://github.com/rust-lang/rust/issues/34701#issuecomment-460804598" target="_blank" title="https://github.com/rust-lang/rust/issues/34701#issuecomment-460804598">this</a> comment which seems to say so</p>



<a name="163636028"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187830-t-compiler/wg-profile-guided-optimization/topic/code%20coverage/near/163636028" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> mw <a href="https://rust-lang.github.io/zulip_archive/stream/187830-t-compiler/wg-profile-guided-optimization/topic/code.20coverage.html#163636028">(Apr 18 2019 at 09:43)</a>:</h4>
<p>I think this is a different kind of instrumentation (although it records similar data)</p>



<a name="163636120"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187830-t-compiler/wg-profile-guided-optimization/topic/code%20coverage/near/163636120" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> mw <a href="https://rust-lang.github.io/zulip_archive/stream/187830-t-compiler/wg-profile-guided-optimization/topic/code.20coverage.html#163636120">(Apr 18 2019 at 09:44)</a>:</h4>
<p>although that comment looks like it does something that actually builds on PGO instrumentation (instead of GCOV)</p>



<a name="165036441"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187830-t-compiler/wg-profile-guided-optimization/topic/code%20coverage/near/165036441" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bebytesback <a href="https://rust-lang.github.io/zulip_archive/stream/187830-t-compiler/wg-profile-guided-optimization/topic/code.20coverage.html#165036441">(May 07 2019 at 02:28)</a>:</h4>
<p>Hi <span class="user-mention" data-user-id="124287">@mw</span> ,<br>
Have there been any discussion about making rustc insert the PGO  instrumentation that @bossmc mention in the above comment?</p>



<a name="165053238"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187830-t-compiler/wg-profile-guided-optimization/topic/code%20coverage/near/165053238" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> mw <a href="https://rust-lang.github.io/zulip_archive/stream/187830-t-compiler/wg-profile-guided-optimization/topic/code.20coverage.html#165053238">(May 07 2019 at 08:45)</a>:</h4>
<p>there are two ways of adding this kind of instrumentation to LLVM IR:</p>
<ul>
<li>Front-end based instrumentation</li>
<li>IR-level instrumentation</li>
</ul>
<p>Both use the same LLVM intrinsics but the first one relies on the compiler front-end (e.g. clang or rustc) to insert them, while the second one lets LLVM automatically insert them during the optimization passes.</p>



<a name="165053312"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187830-t-compiler/wg-profile-guided-optimization/topic/code%20coverage/near/165053312" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> mw <a href="https://rust-lang.github.io/zulip_archive/stream/187830-t-compiler/wg-profile-guided-optimization/topic/code.20coverage.html#165053312">(May 07 2019 at 08:46)</a>:</h4>
<p>Right now, rustc only supports the IR-level approach and (afaik) there are no immediate plans to support the front-end approach.</p>



<a name="165053401"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187830-t-compiler/wg-profile-guided-optimization/topic/code%20coverage/near/165053401" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> mw <a href="https://rust-lang.github.io/zulip_archive/stream/187830-t-compiler/wg-profile-guided-optimization/topic/code.20coverage.html#165053401">(May 07 2019 at 08:48)</a>:</h4>
<p>I don't know the details about this code coverage technique but from taking a quick look at the documentation, it only talks about front-end based instrumentation. not sure if it would also work with IR-level instrumentation.</p>



<a name="165053741"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187830-t-compiler/wg-profile-guided-optimization/topic/code%20coverage/near/165053741" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> mw <a href="https://rust-lang.github.io/zulip_archive/stream/187830-t-compiler/wg-profile-guided-optimization/topic/code.20coverage.html#165053741">(May 07 2019 at 08:54)</a>:</h4>
<p>the project this working group is about is focused on make PGO work though, code coverage would have to be a separate effort</p>



<a name="165088556"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187830-t-compiler/wg-profile-guided-optimization/topic/code%20coverage/near/165088556" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bebytesback <a href="https://rust-lang.github.io/zulip_archive/stream/187830-t-compiler/wg-profile-guided-optimization/topic/code.20coverage.html#165088556">(May 07 2019 at 16:43)</a>:</h4>
<p>Thanks, I understand. Would the working group be interested in looking into the feasibility in adding Front-end based instrumentation?</p>



<a name="165333895"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187830-t-compiler/wg-profile-guided-optimization/topic/code%20coverage/near/165333895" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> mw <a href="https://rust-lang.github.io/zulip_archive/stream/187830-t-compiler/wg-profile-guided-optimization/topic/code.20coverage.html#165333895">(May 10 2019 at 13:02)</a>:</h4>
<p>since I am currently the only member of this working "group" and I'll be going on parental leave next month, I don't think it's likely that this will happen. I personally would also like to avoid adding front-end based instrumentation if possible (it's another feature that needs to be maintained).</p>



<a name="165333983"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187830-t-compiler/wg-profile-guided-optimization/topic/code%20coverage/near/165333983" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> mw <a href="https://rust-lang.github.io/zulip_archive/stream/187830-t-compiler/wg-profile-guided-optimization/topic/code.20coverage.html#165333983">(May 10 2019 at 13:02)</a>:</h4>
<p>I would suggest trying to find out if IR-level instrumentation would also work here.</p>



<a name="165334016"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187830-t-compiler/wg-profile-guided-optimization/topic/code%20coverage/near/165334016" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> mw <a href="https://rust-lang.github.io/zulip_archive/stream/187830-t-compiler/wg-profile-guided-optimization/topic/code.20coverage.html#165334016">(May 10 2019 at 13:03)</a>:</h4>
<p>the corresponding clang commandline option is <code>-fprofile-generate</code></p>



<a name="165334046"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187830-t-compiler/wg-profile-guided-optimization/topic/code%20coverage/near/165334046" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> mw <a href="https://rust-lang.github.io/zulip_archive/stream/187830-t-compiler/wg-profile-guided-optimization/topic/code.20coverage.html#165334046">(May 10 2019 at 13:03)</a>:</h4>
<p>(while FE-based instrumentation is enabled in clang via <code>-fprofile-instr-generate</code>)</p>



<a name="178887441"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187830-t-compiler/wg-profile-guided-optimization/topic/code%20coverage/near/178887441" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Gary Tierney <a href="https://rust-lang.github.io/zulip_archive/stream/187830-t-compiler/wg-profile-guided-optimization/topic/code.20coverage.html#178887441">(Oct 23 2019 at 19:31)</a>:</h4>
<p>Hi, I've been taking a look at getting a prototype going for the front-end based approach, but don't quite know my way around the <code>librustc_codegen_*</code> architecture. Could anyone direct me towards where I could start emitting additional IR for e.g. a <code>Function</code>?</p>
<p>The goal is to emit the LLVM intrinsics mentioned by <span class="user-mention" data-user-id="124287">@mw</span> above, just a single counter for function entry as a starter. My current idea is to add something like <code>emit_profiling_intrinsic(...)</code> to <code>Builder</code> in <code>librustc_codegen_ssa</code> and implement in <code>librustc_codegen_llvm</code>. Then I can start injecting profiling intrinsics from existing functions like <code>codegen_statement</code> in the SSA crate.  Is that reasonable?</p>
<p>I did look at using the existing IR-level approach for this, but don't see any way to reconcile the counters inserted into the IR by LLVM with the counters referenced in the coverage mapping.</p>



<a name="178929069"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187830-t-compiler/wg-profile-guided-optimization/topic/code%20coverage/near/178929069" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> mw <a href="https://rust-lang.github.io/zulip_archive/stream/187830-t-compiler/wg-profile-guided-optimization/topic/code.20coverage.html#178929069">(Oct 24 2019 at 07:59)</a>:</h4>
<p>It's probably best if you re-post this message in the regular <a class="stream" data-stream-id="131828" href="/#narrow/stream/131828-t-compiler">#t-compiler</a> stream for better visibility.</p>



<a name="178933903"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187830-t-compiler/wg-profile-guided-optimization/topic/code%20coverage/near/178933903" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/187830-t-compiler/wg-profile-guided-optimization/topic/code.20coverage.html#178933903">(Oct 24 2019 at 09:14)</a>:</h4>
<p>cc <span class="user-mention" data-user-id="119009">@eddyb</span></p>



<a name="178933933"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187830-t-compiler/wg-profile-guided-optimization/topic/code%20coverage/near/178933933" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/187830-t-compiler/wg-profile-guided-optimization/topic/code.20coverage.html#178933933">(Oct 24 2019 at 09:14)</a>:</h4>
<p>I kind of expected to be around here: <a href="https://github.com/rust-lang/rust/blob/master/src/librustc_codegen_llvm/declare.rs#L133" target="_blank" title="https://github.com/rust-lang/rust/blob/master/src/librustc_codegen_llvm/declare.rs#L133">https://github.com/rust-lang/rust/blob/master/src/librustc_codegen_llvm/declare.rs#L133</a></p>



<a name="178934022"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187830-t-compiler/wg-profile-guided-optimization/topic/code%20coverage/near/178934022" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/187830-t-compiler/wg-profile-guided-optimization/topic/code.20coverage.html#178934022">(Oct 24 2019 at 09:16)</a>:</h4>
<p>but that only declares fns with the intention to define it</p>



<a name="178934274"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187830-t-compiler/wg-profile-guided-optimization/topic/code%20coverage/near/178934274" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/187830-t-compiler/wg-profile-guided-optimization/topic/code.20coverage.html#178934274">(Oct 24 2019 at 09:20)</a>:</h4>
<p>Maybe in the <code>new_block</code> ?</p>



<a name="178934337"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187830-t-compiler/wg-profile-guided-optimization/topic/code%20coverage/near/178934337" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/187830-t-compiler/wg-profile-guided-optimization/topic/code.20coverage.html#178934337">(Oct 24 2019 at 09:21)</a>:</h4>
<p><a href="https://github.com/rust-lang/rust/blob/e369d87b015a84653343032833d65d0545fd3f26/src/librustc_codegen_ssa/mir/mod.rs#L197" target="_blank" title="https://github.com/rust-lang/rust/blob/e369d87b015a84653343032833d65d0545fd3f26/src/librustc_codegen_ssa/mir/mod.rs#L197">https://github.com/rust-lang/rust/blob/e369d87b015a84653343032833d65d0545fd3f26/src/librustc_codegen_ssa/mir/mod.rs#L197</a></p>



<a name="178934345"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187830-t-compiler/wg-profile-guided-optimization/topic/code%20coverage/near/178934345" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/187830-t-compiler/wg-profile-guided-optimization/topic/code.20coverage.html#178934345">(Oct 24 2019 at 09:21)</a>:</h4>
<p>You could add it to the <code>"start"</code> block of a function, or maybe earlier</p>



<a name="178934453"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187830-t-compiler/wg-profile-guided-optimization/topic/code%20coverage/near/178934453" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Gary Tierney <a href="https://rust-lang.github.io/zulip_archive/stream/187830-t-compiler/wg-profile-guided-optimization/topic/code.20coverage.html#178934453">(Oct 24 2019 at 09:23)</a>:</h4>
<p><span class="user-mention" data-user-id="132920">@gnzlbg</span> ah, thanks. I think <code>codegen_mir(...)</code> has the bulk of what I'm looking for. This should get me started on emitting the intrinsics.</p>



<a name="178934519"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187830-t-compiler/wg-profile-guided-optimization/topic/code%20coverage/near/178934519" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/187830-t-compiler/wg-profile-guided-optimization/topic/code.20coverage.html#178934519">(Oct 24 2019 at 09:24)</a>:</h4>
<p>I think <span class="user-mention" data-user-id="119009">@eddyb</span> or @bjorn3 are familiar with that code, so it might make sense to ping them if you have questions</p>



<a name="178934562"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187830-t-compiler/wg-profile-guided-optimization/topic/code%20coverage/near/178934562" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/187830-t-compiler/wg-profile-guided-optimization/topic/code.20coverage.html#178934562">(Oct 24 2019 at 09:25)</a>:</h4>
<p>The birds eye is that <code>librustc_codegen_ssa</code> is the "API" for generating code for a backend from MIR</p>



<a name="178934581"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187830-t-compiler/wg-profile-guided-optimization/topic/code%20coverage/near/178934581" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/187830-t-compiler/wg-profile-guided-optimization/topic/code.20coverage.html#178934581">(Oct 24 2019 at 09:25)</a>:</h4>
<p>and that the different backends (e.g. <code>librustc_codegen_llvm</code>, <code>librustc_codegen_clif</code>, etc.) implement that API</p>



<a name="178934641"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187830-t-compiler/wg-profile-guided-optimization/topic/code%20coverage/near/178934641" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/187830-t-compiler/wg-profile-guided-optimization/topic/code.20coverage.html#178934641">(Oct 24 2019 at 09:26)</a>:</h4>
<p>You might get away touching only the LLVM backend (e.g. for the <code>"start"</code> label, also insert some code coverage code)</p>



<a name="178934681"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187830-t-compiler/wg-profile-guided-optimization/topic/code%20coverage/near/178934681" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/187830-t-compiler/wg-profile-guided-optimization/topic/code.20coverage.html#178934681">(Oct 24 2019 at 09:27)</a>:</h4>
<p>but I can't tell you whether that's a good idea</p>



<a name="178934921"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187830-t-compiler/wg-profile-guided-optimization/topic/code%20coverage/near/178934921" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Gary Tierney <a href="https://rust-lang.github.io/zulip_archive/stream/187830-t-compiler/wg-profile-guided-optimization/topic/code.20coverage.html#178934921">(Oct 24 2019 at 09:31)</a>:</h4>
<p>Thanks, great info. I think I'll start with adding something like a new<code>ProfilingInstrumentationMethods</code> to <code>librustc_codegen_ssa</code> that I can implement for the LLVM backend. That'll let me insert counters generically from the "API" crate and the LLVM backend can look at these counters and associate it with coverage maps. I can start stripping it back later if it living in <code>librustc_codegen_ssa</code> turns out to be a bad idea.</p>



<a name="178971848"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187830-t-compiler/wg-profile-guided-optimization/topic/code%20coverage/near/178971848" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/187830-t-compiler/wg-profile-guided-optimization/topic/code.20coverage.html#178971848">(Oct 24 2019 at 16:46)</a>:</h4>
<p><span class="user-mention" data-user-id="228861">@Gary Tierney</span> hey! so I did a bit of research last year about this for a contract that never happened, and I think I might remember a few things</p>



<a name="178971849"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187830-t-compiler/wg-profile-guided-optimization/topic/code%20coverage/near/178971849" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/187830-t-compiler/wg-profile-guided-optimization/topic/code.20coverage.html#178971849">(Oct 24 2019 at 16:46)</a>:</h4>
<p>my suggestions is not adding another trait but just methods to BuilderMethods or w/e</p>



<a name="178971850"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187830-t-compiler/wg-profile-guided-optimization/topic/code%20coverage/near/178971850" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/187830-t-compiler/wg-profile-guided-optimization/topic/code.20coverage.html#178971850">(Oct 24 2019 at 16:46)</a>:</h4>
<p>specifically for inserting runtime calls, at least</p>



<a name="178974730"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187830-t-compiler/wg-profile-guided-optimization/topic/code%20coverage/near/178974730" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Gary Tierney <a href="https://rust-lang.github.io/zulip_archive/stream/187830-t-compiler/wg-profile-guided-optimization/topic/code.20coverage.html#178974730">(Oct 24 2019 at 17:16)</a>:</h4>
<p>Hi <span class="user-mention" data-user-id="119009">@eddyb</span>  :)</p>
<p>Yep, that seems reasonable. I don't quite get the delineation between the various traits at the moment, I'd just found <code>DebugInfoBuilderMethods</code> and started copying from that ;).</p>
<p>My intention at the moment is to have an API for inserting runtime calls in <code>BuilderMethods</code>, et al. and leave it up to the LLVM backend to map source spans to profiling counters when it begins emitting a function or compiling a module.</p>



<a name="178974814"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187830-t-compiler/wg-profile-guided-optimization/topic/code%20coverage/near/178974814" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/187830-t-compiler/wg-profile-guided-optimization/topic/code.20coverage.html#178974814">(Oct 24 2019 at 17:17)</a>:</h4>
<p><code>FooBuilderMethods</code> is a bit of an anti-pattern, and debuginfo is kinda special, so I'd avoid mimicking it</p>



<a name="178975765"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187830-t-compiler/wg-profile-guided-optimization/topic/code%20coverage/near/178975765" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Gary Tierney <a href="https://rust-lang.github.io/zulip_archive/stream/187830-t-compiler/wg-profile-guided-optimization/topic/code.20coverage.html#178975765">(Oct 24 2019 at 17:26)</a>:</h4>
<p>Noted, I'll just add some simple functions to <code>BuilderMethods</code> for now.. Getting the backend agnostic code to start emitting the calls doesn't <br>
seem too difficult.</p>
<p>I'll report any progress on <a href="https://github.com/rust-lang/rust/issues/34701" target="_blank" title="https://github.com/rust-lang/rust/issues/34701">https://github.com/rust-lang/rust/issues/34701</a>.</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>